package com.lagou.blog.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.blog.dao.ArticleMapper;
import com.lagou.blog.pojo.Article;
import com.lagou.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("articleService")
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    // 设置每页显示5条数据
    private final static Integer pageSize = 5;

    public PageInfo<Article> selectAll(Integer pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        List<Article> articles = articleMapper.selectAll();
        PageInfo<Article> pageInfo = new PageInfo<Article>(articles);
        return pageInfo;
    }
}
